package ${packageName};


import com.changgou.pojo.${pojoNameBig};
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;

import java.util.List;
import java.util.Map;

@Service
@Transactional
public class ${pojoNameBig}ServiceImpl implements ${pojoNameBig}Service {
@Autowired
${pojoNameBig}Mapper ${pojoNameLte}Mapper;

@Override
public ${pojoNameBig} findById(Long id) {
return ${pojoNameLte}Mapper.selectByPrimaryKey(id);
}

@Override
public List<${pojoNameBig}> findAll() {
return ${pojoNameLte}Mapper.selectAll();
}

@Override
public Page<${pojoNameBig}> findPage(int currentPage, int pageSize, Map
<String, Object> searchMap) {
PageHelper.startPage(currentPage, pageSize);
//添加查询条件
Example example = new Example(${pojoNameBig}.class);
Example.Criteria criteria = example.createCriteria();
if (searchMap != null) {
if (!StringUtils.isEmpty((String) searchMap.get("name"))) {
criteria.andLike("name", "%" + searchMap.get("name") + "%");
}
if (!StringUtils.isEmpty("letter")) {
criteria.andEqualTo(searchMap.get("letter"));
}
}


Page<${pojoNameBig}> ${pojoNameLte}s = (Page<${pojoNameBig}>) ${pojoNameLte}Mapper.selectByExample(example);

return ${pojoNameLte}s;
}

@Override
public void add(${pojoNameBig} ${pojoNameLte}) {
${pojoNameLte}Mapper.insertSelective(${pojoNameLte});
}

@Override
public void update(${pojoNameBig} ${pojoNameLte}) {
${pojoNameLte}Mapper.updateByPrimaryKey(${pojoNameLte});
}

@Override
public void deleteByIds(Long[] ids) {
for (Long id : ids) {
${pojoNameLte}Mapper.deleteByPrimaryKey(id);
}

}
}
